<template>
	<div class="boxStyle">
		<el-row type="flex" class="row-bg" justify="start" style="margin-bottom: 10px;">
			<el-col :span="1" style="margin-top: 5px;padding-left: 10px;width: 80px;">昵称:</el-col>
			<el-col :span="2">
				<el-input v-model="sName" placeholder="请输入名称" size="small"></el-input>
			</el-col>
			<el-col :span="1" style="margin-top: 5px;padding-left: 10px;">手机号 :</el-col>
			<el-col :span="3" style="margin-right: 10px;">
				<el-input v-model="sPhone" placeholder="请输入手机号" size="small"></el-input>
			</el-col>
			<el-col :span="1" style="margin-top: 5px;padding-left: 10px;width: 80px;">订单号:</el-col>
			<el-col :span="3" style="margin-right: 10px;">
				<el-input v-model="oderNum" placeholder="请输入订单号" size="small"></el-input>
			</el-col>
			<el-col :span="1" style="margin-top: 5px;padding-left: 10px;">状态 :</el-col>
			<el-col :span="2">
				<el-select v-model="status" placeholder="请选择" size="small" style="width: 100px;">
					<el-option value="" label="全部"></el-option>
					<el-option key="0" label="待审核" value="0"></el-option>
					<el-option key="1" label="已审核" value="1"></el-option>
					<el-option key="2" label="拒绝" value="2"></el-option>
				</el-select>
			</el-col>
			<el-col :span="1" style="margin-left: 50px;">
				<el-button type="warning" icon="el-icon-search" size="small" @click="search">查找</el-button>
			</el-col>
		</el-row>
		<el-row type="flex" class="row-bg" justify="start" style="margin-bottom: 10px;">
			<el-col :span="6" style="margin-right: 10px;">
				<el-button type="warning" size="small" @click="dealList(1)" v-if="dealShow!==-1">批量通过</el-button>
				<el-button type="warning" size="small" @click="dealList(2)" v-if="dealShow!==-1">批量拒绝</el-button>
			</el-col>
		</el-row>
		<el-table :data="tableData" border style="width:100%;margin-bottom: 10px;"  @selection-change="handleSelectionChange">
			<el-tableref="multipleTable" :data="tableData" tooltip-effect="dark" style="width: 100%">
				<el-table-column type="selection" width="50"></el-table-column>
				<el-table-column prop="orderId" label="订单号" width="220"></el-table-column>
				<el-table-column prop="nickName" label="用户昵称" width="100"></el-table-column>
				<el-table-column prop="mobile" label="手机号" width="120"></el-table-column>
				<el-table-column prop="applyTime" label="申请时间" width="200" :formatter="dateFormat"></el-table-column>
				<el-table-column prop="applyMoney" label="提现金额" width="100"></el-table-column>
				<el-table-column prop="status" label="状态" width="90">
					<template slot-scope="scope">
						<span v-if="scope.row.status==0">待审核</span>
						<span v-if="scope.row.status==1" style="color: green;">已通过</span>
						<span v-if="scope.row.status==2" style="color: red;">已拒绝</span>
					</template>
				</el-table-column>
				<el-table-column prop="dealTime" label="处理时间" width="200" :formatter="dateFormat"></el-table-column>
				<el-table-column prop="resutcode" label="状态" width="100"></el-table-column>
				<el-table-column prop="resutmsg" label="返回信息" width="120"></el-table-column>
				<el-table-column label="操作" min-width="100">
					<template slot-scope="scope">
						<el-button size="mini" type="danger" v-if="scope.row.status==0&&dealShow!==-1" style="margin-top: 5px;margin-left: 0px;" @click="updata(scope.row.id,1)">通过</el-button>
						<el-button size="mini" type="danger" v-if="scope.row.status==0&&dealShow!==-1" @click="updata(scope.row.id,2)">拒绝</el-button>
					</template>
				</el-table-column>
		</el-table>
		<el-pagination background @current-change="handleCurrentChange" :current-page="Page" :page-size="size" layout="prev, pager, next,total, slot" :total="totals">
			<span style="margin-top: -2px;color: #606266;font-weight: 100;">第<el-input type="text" v-model="inputPage" style="width: 60px;margin: 0 5px;"/>页<el-button size="mini" style="background: #409EFF; color: #fff;margin:0 5px;" @click="handleCurrentChange(inputPage)">跳转</el-button><span>总计{{totalPage}}页</span></span>
		</el-pagination>
	</div>
</template>

<script>
	import { formatDate } from 'static/js/date.js'
	import qs from "qs"
	import axios from "axios"
	export default {
		data() {
			return {
				Page: 1, //当前页
				totals: 0, //分页总条数
				size: 0, //每页条数
				purl: this.$store.state.purl, //权限数组
				sPhone: "", //搜索手机号
				sName: "", //搜索名称
				price: 0, //充值金额
				desc: "", //充值说明
				stime: [],
				status: "",
				tableData: [],
				multipleSelection: "",
				user: {},
				isDisabled: false,
				totalPage: 1,
				inputPage: 1,
				dealShow:0,
				oderNum:""
			}
		},
		activated() {
			this.Page = 1;
			this.inputPage = 1;
			this.load(1);
			this.sPhone="";
			this.sName="";
			this.status="";
			this.oderNum="";
//			this.dealShow = this.purl[0].findIndex((val) => val === "/interface/diswithdrawl/status")
		},
		mounted() {
			this.load(1);
			//			this.addShow = this.purl[0].findIndex((val) => val === "/interface/dictionary/create") //判断是否拥有增加权限
			//			console.log(this.addShow)
		},
		methods: {
			load(num) {
				axios.get("/interface/diswithdrawl/list?pageNo=" + num).then((res) => {
					this.tableData = res.data.data.list; //list数据
						this.totals = res.data.data.pageBean.totalRow; //总条数
						this.size = res.data.data.pageBean.pageSize; //每页条数 
						this.totalPage = res.data.data.pageBean.totalPage; //总页数
					/*this.logOptions=res.data.data.logistics;*/
				})
			},
			dateFormat: function(row, column) {
				var date
				if(row[column.property]) {
					date = new Date(parseInt(row[column.property]))
					date = formatDate(date, 'yyyy-MM-dd hh:mm:ss')
				}
				if(date == undefined) {
					return "";
				}
				return date;
			},
			handleCurrentChange(val) {
				var thit = this;
				axios.post("/interface/diswithdrawl/list?", qs.stringify({
					mobile: thit.sPhone,
					nickName: thit.sName,
					status: thit.status,
					orderId:thit.oderNum,
					pageNo: val
				})).then((res) => {
					this.tableData = res.data.data.list; //list数据
						this.totals = res.data.data.pageBean.totalRow; //总条数
						this.size = res.data.data.pageBean.pageSize; //每页条数 
						this.totalPage = res.data.data.pageBean.totalPage; //总页数
				})
			},
			search() {
				var thit = this;
				this.inputPage=1;
				this.currentPage=1;
				axios.post("/interface/diswithdrawl/list?", qs.stringify({
					mobile: thit.sPhone,
					nickName: thit.sName,
					status: thit.status,
					orderId:thit.oderNum,
					pageNo:1
				})).then((res) => {
					this.tableData = res.data.data.list; //list数据
						this.totals = res.data.data.pageBean.totalRow; //总条数
						this.size = res.data.data.pageBean.pageSize; //每页条数 
						this.totalPage = res.data.data.pageBean.totalPage; //总页数
				})
			},
			updata(id, stu) {
				var startTime
				var endTime
				if(this.stime != '') {
					startTime = formatDate(this.stime[0], 'yyyy-MM-dd');
					endTime = formatDate(this.stime[1], 'yyyy-MM-dd');
				} else {
					startTime = "";
					endTime = "";
				}
				$("#dic").modal("show")
				$(".dic li a").text("用户余额详情")
				axios.post("/interface/diswithdrawl/status?ids=" + id + "&status=" + stu).then((res) => {
					var msg = res.data
					if(msg.code == 1) {
						$("#dic").modal("hide");
						if(stu==1){
							this.$message.success("审核成功");
						}else{
							this.$message.success("拒绝成功");
						}
						this.load(1);
					} else {
						this.$message.success(msg.msg);
					}
				})
			},
			handleSelectionChange(val) {
				var strId = "";
				for(var i = 0; i < val.length; i++) {
					strId += val[i].id + ",";
				}
				strId = strId.slice(0, strId.length - 1);
				this.multipleSelection=strId;
			},
			dealList(stu) {
				if(this.multipleSelection==""){
					this.$message.error("请选择需要处理的数据");
					return;
				}
				axios.post("/interface/diswithdrawl/status?ids=" + this.multipleSelection + "&status=" + stu).then((res) => {
					var msg = res.data
					if(msg.code == 1) {
						$("#dic").modal("hide");
						if(stu==1){
							this.$message.success("审核成功");
						}else{
							this.$message.success("拒绝成功");
						}
						this.load(1);
					} else {
						this.$message.success(msg.msg);
					}
				})
			}
		}
	}
</script>

<style>

</style>